package com.uphone.magicleafteacher.pro.activity;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.radish.baselibrary.Intent.IntentData;
import com.radish.baselibrary.utils.LogUtils;
import com.uphone.magicleafteacher.R;
import com.uphone.magicleafteacher.base.BaseGActivity;
import com.uphone.magicleafteacher.pro.adapter.PracticeAdapter;
import com.uphone.magicleafteacher.util.AudioPlayProgressUtil;
import com.uphone.magicleafteacher.util.CommonUtil;
import com.uphone.magicleafteacher.util.GsonUtils;
import com.uphone.magicleafteacher.vo.AudioWorkDetailBean;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;

public class PracticeDetailActivity extends BaseGActivity {
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    @BindView(R.id.iv_close)
    ImageView ivClose;
    @BindView(R.id.iv_play)
    ImageView ivPlay;
    private AudioPlayProgressUtil util;
    private PracticeAdapter mAdapter;
    @IntentData
    private String audioPath = "";
    @IntentData
    private ArrayList<AudioWorkDetailBean.AudioWorkBean.ChaptersBean> chapterList;

    @Override
    protected void initLayoutBefore() {
        super.initLayoutBefore();
        isUseImmersionBar = true;
    }

    @Override
    protected void initBundle() {

    }

    @Override
    protected int initLayout() {
        return R.layout.activity_practice_detail;
    }

    @Override
    protected void initView() {
        util = new AudioPlayProgressUtil(ivPlay);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        mAdapter = new PracticeAdapter(chapterList);
        recyclerView.setAdapter(mAdapter);
    }

    @Override
    protected void initTitle() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {

    }

    @OnClick({R.id.iv_close, R.id.iv_play})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_close:
                finish();
                break;
            case R.id.iv_play:
                if (!view.isSelected()) {
                    util.play(audioPath);
                } else {
                    util.stop();
                }
                break;
        }
    }
}
